Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next

Naming Windows

This section describes the functions that set and retrieve a window's title.

SetWTitle

Sets a window's title.

pascal void SetWTitle (WindowPtr theWindow,
                     ConstStr255Param title);
theWindow
A pointer to the window's window record.
title
The new window title.

DESCRIPTION

The SetWTitle function changes a window's title to the specified string, both in the window record and on the screen, and redraws the window's frame as necessary.

When the user opens a previously saved document, you typically create a new (invisible) window with the title "untitled" and then call SetWTitle to give the window the document's name before displaying it. You also call SetWTitle when the user saves a document under a new name.

To suppress the title in a window with a title bar, pass an empty string, not nil .

Always use SetWTitle instead of directly changing the title in a window's window record.

GetWTitle

Gets a window's title.

pascal void GetWTitle (WindowPtr theWindow,
                     Str255 title);
theWindow
A pointer to the window record.
title
The window title.

DESCRIPTION

The GetWTitle function returns the title of the window in the title parameter.

Your application seldom needs to determine a window's title. It might need to do so, however, when presenting user dialog boxes during operations that can affect multiple files. A spell-checking command, for example, might display a dialog box that lets the user select from all currently open documents.

When you need to retrieve a window's title, you should always use GetWTitle instead of reading the title from a window's window record.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next